- /* sdcrec_e.cpp by K.Tsuru */
- // function ID 3507 DRADIX, constant
- /*****************************************
- SDouble class
- reciprocal of the base of natural logarithm
- exp(-1)
- *****************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
-
- class BSRecExp1 : public BinarySplittingA1C<SLong> {
- public:
- BSRecExp1(long L, long prec) : BinarySplittingA1C<SLong>(L, prec) {}
-
- void setAC(long k, SLong& a, SLong& c) {
- a.SetSmall((k&1) ? 1 : (-1)); // A(k) = (-1)^(k-1)
- c.SetInt(k + 1); // C(k) = k + 1;
- }
-
- SDouble getValue() {
- putTogether();
- return BinarySplittingA1C<SLong>::getValue() + 1.0;
- }
- };
-
- static SDouble* recE = NULL;//keep in the static memory
- static uint recE_size = 0;
-
- void RecEFree(){ //free the memory of recE
- if(recE_size == 0) return;
- delete recE; recE = NULL; recE_size = 0;
- }
-
- /********************************************************
- 1/e If "invE=true", it returns "1/E()" else evaluates by
- the "class BSRecExp1" above for test "RecE()*E()=1" ?.
- *********************************************************/
- SDouble RecE(bool invE){
- SDouble temp;
- uint rE_size = temp.MaxSize();
- if( recE_size < rE_size ){
- if(recE == NULL) recE = new SDouble;
- }
- if(invE) {
- temp = E();
- *recE = DReciprocal(temp);
- } else {
- long prec = long(temp.EffFig() + temp.Hidden()) * DFIGURES;
- long L = upToExpSeries(prec, 0.0);
-
- BSRecExp1 re(L, prec);
- *recE = re.getValue();
- }
- recE_size = rE_size;
-
- return *recE;
- }
sdcrec_e.cpp : last modifiled at 2017/06/23 10:01:52(1,519 bytes)
created at 2017/10/07 10:21:15
The creation time of this html file is 2017/10/07 10:30:03 (Sat Oct 07 10:30:03 2017).